<template>
<span>固定三个子组件：</span>
  <div v-for="item in 3" :key="item">
    <child :ref='addChildRef'/>
  </div>
</template>

<script lang="ts" setup>
 import child from './children-component.vue'
 import {  ref } from 'vue';
//   const childRef = ref<InstanceType<typeof child>>()

  // 子组件实例数组
  const childRefs = ref<any>([])

  // 通过 addChildRef 方法向 childRefs 添加子组件实例
  const addChildRef = (el: any) => {
    childRefs.value.push(el)
  }

</script>

